package com.cheng.io.input;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * 数据字节输入流
 * 专门读取DataOutputStream写入的数据，读取数据的顺序和写入的顺序要保持一致
 */
public class DataInputStreamTest01 {
    public static void main(String[] args) {
        try (
                DataInputStream inputStream = new DataInputStream(new FileInputStream("io/resources/data"));
        ) {
            byte b = inputStream.readByte();
            short s = inputStream.readShort();
            int i = inputStream.readInt();
            long l = inputStream.readLong();
            float f = inputStream.readFloat();
            double d = inputStream.readDouble();
            boolean flag = inputStream.readBoolean();
            char c = inputStream.readChar();
            String str = inputStream.readUTF();

            System.out.println("b = " + b);
            System.out.println("s = " + s);
            System.out.println("i = " + i);
            System.out.println("l = " + l);
            System.out.println("f = " + f);
            System.out.println("d = " + d);
            System.out.println("flag = " + flag);
            System.out.println("c = " + c);
            System.out.println("str = " + str);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
